package org.bb.io.streamReader;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;

public class MyTest {
	public static void main(String[] args) {
		test01();
	}

	public static void test01() {
		try {
			// 创建一个字符流输入/输出流 对象
			Reader in = new InputStreamReader(new FileInputStream("C:\\Users\\bql\\Desktop\\新建文件夹\\ClassMaster.java"),
					"utf-8");
			Writer out = new OutputStreamWriter(new FileOutputStream("C:\\Users\\bql\\Desktop\\新建文件夹\\bbb.java"),
					"utf-8");
			// 创建一个读取字符
			char[] ch = new char[1024];
			// 读取
			int len = in.read(ch);
			while (len != -1) {
				// 写入
				out.write(ch, 0, len);
				// 改变循环因子
				len = in.read(ch, 0, len);
			}

			out.flush();
			in.close();
			out.close();
			System.out.println("字符流读取完成");
		} catch (Exception e) {
			System.out.println("字符流输出异常:" + e.getMessage());
		}
	}
}
